<template>
  <div>
    <el-card>
      <div slot="header" class="clearfix relative">
        <span class="title-icon">发票配置</span>
        <el-button
          type="success"
          size="mini"
          class="header-save-btn"
          @click="changeInfo"
        >
          保存
        </el-button>
      </div>

      <el-form
        size="mini"
        :model="info"
        label-position="left"
        ref="info"
        label-width="98px"
        style="width:200px"
      >
        <el-form-item
          label="电子发票数"
          prop="crmnumber"
          :rules="[
            { required: true, message: '电子发票数不能为空' },
            { type: 'number', message: '电子发票数必须为数字值' }
          ]"
        >
          <el-input
            type="crmnumber"
            v-model.number="info.crmnumber"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item
          label="纸质普通数"
          prop="papnumber"
          :rules="[
            { required: true, message: '纸质普通数不能为空' },
            { type: 'number', message: '纸质普通数必须为数字值' }
          ]"
        >
          <el-input
            type="papnumber"
            v-model.number="info.papnumber"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item
          label="纸质专票数"
          prop="spenumber"
          :rules="[
            { required: true, message: '纸质专票数不能为空' },
            { type: 'number', message: '纸质专票数必须为数字值' }
          ]"
        >
          <el-input
            type="spenumber"
            v-model.number="info.spenumber"
            autocomplete="off"
          ></el-input>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
import { m } from "@/store/yg/common/local";
import { ajax } from "@/store/yg/common/utils";
export default {
  data() {
    return {
      info: {
        crmnumber: "",
        papnumber: "",
        spenumber: ""
      }
    };
  },
  mounted() {
    this.selectOne();
  },
  methods: {
    m(k) {
      return m(k);
    },
    selectOne() {
      ajax("list", {}).then(
        res => {
          //console.log(res);
          debugger;
          if (res.code != 200) {
            this.info = res.list[0];
          } else {
            //console.log(res.data);
          }
        },
        error => {
          //console.log(error);
        }
      );
    },

    changeInfo() {
      ajax("save", this.info).then(
        res => {
          //console.log(res);

          if (res.code != 200) {
            this.$message.error(res.message);
          } else {
            //console.log(res.data);
          }
        },
        error => {
          console.log(error);
        }
      );
    }
  }
};
</script>

<style scoped>
/deep/ .el-input {
  width: ;
}
</style>
